package com.bh.framework.utils;

import java.io.InputStream;

import org.apache.http.util.EncodingUtils;

import android.content.Context;

/**
 * 数据解析类
 * @author fancy
 *
 */
public class DataUtils {

	/**
	 * 从 assets 获取文本
	 * @param fileName
	 * @param context
	 * @return
	 */
	public  static String getAssetsText(String fileName,Context context){
		String text= null; 
		try{ 
		   InputStream in = context.getResources().getAssets().open(fileName);
		   int length = in.available();         
		   byte [] buffer = new byte[length];        
		   in.read(buffer);            
		   text = EncodingUtils.getString(buffer, "UTF-8");     
		}catch(Exception e){ 
		      e.printStackTrace();     
		      text= null; 
		}
		if(text!=null){
//			Log.e("VirtualJsonData="+text);
		}else{
			Log.e("VirtualJsonData=nononononononotext");	
		}
		return text;
	}
}
